﻿namespace WMS6.Web.Outbound
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class OrderSelectionQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlBatchPickMaxCount;
        protected DropDownList ddlBatchPickMaxCube;
        protected DropDownList ddlCartonGroup;
        protected DropDownList ddlEnablePacking;
        protected DropDownList ddlIsDefault;
        protected DropDownList ddlIsDefaultOper;
        protected DropDownList ddlMaxOrders;
        protected DropDownList ddlOrderSelectionID;
        protected HtmlForm F7020;
        protected HtmlInputHidden hdnActionID;
        protected Label lblAllocationQuery;
        protected Label lblBatchPickMaxCount;
        protected Label lblBatchPickMaxCube;
        protected Label lblCartonGroup;
        protected Label lblEnablePacking;
        protected Label lblIsDefault;
        protected Label lblMaxOrders;
        protected Label lblOrderSelectionID;
        protected HtmlLink mycss;
        protected TextBox txtBatchPickMaxCount;
        protected TextBox txtBatchPickMaxCube;
        protected TextBox txtCartonGroup;
        protected TextBox txtEnablePacking;
        protected TextBox txtMaxOrders;
        protected TextBox txtOrderSelectionID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("OrderSelectionList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("OrderSelectionList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlOrderSelectionID, 0);
            base.InitQueryDDL(this.ddlCartonGroup, 0);
            base.InitQueryDDL(this.ddlEnablePacking, 0);
            base.InitQueryDDL(this.ddlMaxOrders, 0);
            base.InitQueryDDL(this.ddlBatchPickMaxCount, 0);
            base.InitQueryDDL(this.ddlBatchPickMaxCube, 0);
            base.InitQueryDDL(this.ddlIsDefaultOper, 0);
            base.InitIsActiveDDL(this.ddlIsDefault, 0);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
                this.LoadData();
            }
        }

        public string BatchPickMaxCount
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtBatchPickMaxCount.Text.Trim()))
                {
                    return base.GetParamsString(this.txtBatchPickMaxCount.Text.Trim(), this.ddlBatchPickMaxCount.SelectedValue);
                }
                return "";
            }
        }

        public string BatchPickMaxCube
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtBatchPickMaxCube.Text.Trim()))
                {
                    return base.GetParamsString(this.txtBatchPickMaxCube.Text.Trim(), this.ddlBatchPickMaxCube.SelectedValue);
                }
                return "";
            }
        }

        public string CartonGroup
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCartonGroup.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCartonGroup.Text.Trim(), this.ddlCartonGroup.SelectedValue);
                }
                return "";
            }
        }

        public string EnablePacking
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEnablePacking.Text.Trim()))
                {
                    return base.GetParamsString(this.txtEnablePacking.Text.Trim(), this.ddlEnablePacking.SelectedValue);
                }
                return "";
            }
        }

        public string IsDefault
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsDefault.Text.Trim()))
                {
                    return base.GetParamsString(this.ddlIsDefault.Text.Trim(), this.ddlIsDefaultOper.SelectedValue);
                }
                return "";
            }
        }

        public string MaxOrders
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtMaxOrders.Text.Trim()))
                {
                    return base.GetParamsString(this.txtMaxOrders.Text.Trim(), this.ddlMaxOrders.SelectedValue);
                }
                return "";
            }
        }

        public string OrderSelectionID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOrderSelectionID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOrderSelectionID.Text.Trim(), this.ddlOrderSelectionID.SelectedValue);
                }
                return "";
            }
        }
    }
}

